<?php
class AttendModel extends Model{
	protected $table = "";
	protected $pk='id';
	//表中的字段
	//protected $fields=$this->fields();
	
	//获取数据库动态考勤表的字段
	public function getFields($class){
		$sql = "select column_name FROM information_schema.columns WHERE table_schema='kq' AND table_name='".$class."' ";
		return $this->db->getAll($sql);
	}
	
	/*private function fields(){
		$row=$this->getFields();
        $fields = array();
        foreach ($row as $v) {
            $fields[] = $v['column_name'] ;
        }
        $this->fields=$fields;
	}*/

	public function studentlist($class,$c){
		$sql = "select id,NO,name,".$c." from ".$class." order by id ASC";
		return $this->db->getAll($sql);
	}

	public function studentlist1($class,$c){
		$sql = "select id,NO,name,".$c." from ".$class." order by id ASC";
		return $this->db->getAll1($sql);
	}

	public function attend($key,$course,$NO,$class){
    	$sql ="update ".$class." set $key=$key+".$course." where NO='".$NO."'";
    	if($this->db->query($sql)){
    		return true;
    	}else{
    		return false;
    	}
    }

    public function attend2($c1,$c2,$NO,$class,$key1,$key2){
    	$sql ="update ".$class." set $key1=$key1+".$c1.",$key2=$key2+".$c2." where NO='".$NO."'";
    	if($this->db->query($sql)){
    		return true;
    	}else{
    		return false;
    	}
    }
	
}

?>